<?php include $this->getViewFile('/common/Head') ?>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
  <?php include $this->getViewFile('/common/Nav') ?>
  <div class="h_a">搜索</div>
  <form method="post" action="<?php echo AdminBase::U('index') ?>">
    <div class="search_type cc mb10">
      <div class="mb10"> <span class="mr20">
      上传时间：
        <input type="text" name="start_uploadtime" class="input length_2 J_date" value="<?php echo $start_uploadtime ?>">
        -
        <input type="text" class="input length_2 J_date" name="end_uploadtime" value="<?php echo $end_uploadtime ?>">
        附件类型：
        <input type="text" class="input length_2" name="fileext" style="width:80px;" value="<?php echo $fileext ?>" placeholder="类型：jpg、png">
          附件名称：
        <input type="text" class="input length_2" name="filename" style="width:200px;" value="<?php echo $filename ?>" placeholder="请输入附件名称...">
        <button class="btn">搜索</button>
        </span> </div>
    </div>
  </form>
  <form name="myform" action="<?php echo AdminBase::U('delete') ?>" method="post" class="J_ajaxForm">
  <div class="table_list">
  <table width="100%" cellspacing="0">
      <thead>
        <tr>
          <td width="45" align="center"><input type="checkbox" class="J_check_all" data-direction="x" data-checklist="J_check_x">全选</td>
          <td width="40" align="center">ID</td>
          <td width="70" align="center" >上传用户ID </td>
          <td>附件名称</td>
        <td width="100" align="center">附件大小</td>
        <td width="120" align="center">上传时间</td>
        <td width="100" align="center">管理操作</td>
      </tr>
      </thead>
      <tbody>
      <?php
	  foreach($data as $rs){
	  ?>
        <tr>
          <td align="center"><input type="checkbox" class="J_check" data-yid="J_check_y" data-xid="J_check_x" name="aid[]" value="<?php echo $rs->aid?>" id="att_<?php echo $rs->aid?>" /></td>
          <td align="center"><?php echo $rs->aid?></td>
          <td align="center">
          <?php
		  if($rs->isadmin){
			  echo '[后台]';
		  }
		  if($rs->userid){
			  echo $rs->isadmin?AdminUser::model()->getByUidFindName($rs->userid):$rs->userid;
		  }else{
			 echo '游客'; 
		  }
		  ?>
          </td>
          <td >
          <img src="<?php echo $staticUrl; ?>statics/images/ext/<?php echo $rs->fileext?>.gif" /><?php echo $rs->filename?>
          <br/>
          图片地址：<input name="" type="text" class="input length_6" value="<?php echo ConfigModel::model()->getConfig('sitefileurl').$rs->filepath?>">
          </td>
          <td align="center"><?php echo ceil($rs->filesize/1024) ?> KB</td>
          <td align="center"><?php echo date('Y-m-d H:i:s',$rs->uploadtime)?></td>
          <td align="center"><a href="javascript:preview(<?php echo $rs->aid?>, '<?php echo $rs->filename?>','<?php echo ConfigModel::model()->getConfig('sitefileurl').$rs->filepath?>')">预览</a> | <a class="J_ajax_del" href="<?php echo AdminBase::U('delete',array('aid'=>$rs->aid)) ?>">删除</a></td>
        </tr>
      <?php
	  }
	  ?>
      </tbody>
    </table>
    <div class="p10">
        <div class="pages"> <?php echo $Page;?> </div>
      </div>
  </div>
  <div class="btn_wrap">
      <div class="btn_wrap_pd">
        <label class="mr20"><input type="checkbox" class="J_check_all" data-direction="y" data-checklist="J_check_y">全选</label> 
        <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">删除附件</button>
      </div>
    </div>
  </form>
</div>
<script src="<?php echo $staticUrl; ?>statics/js/common.js?v"></script>
<script src="<?php echo $staticUrl; ?>statics/js/content_addtop.js?v"></script>
<script type="text/javascript">
//附件预览
function preview(id, name, filepath) {
    if (IsImg(filepath)) {
        Wind.use('artDialog', 'imgready', function () {
            imgReady(filepath, function () {
                var width = 0,
                    maxWidth = 500,
                    maxHeight = 500,
                    height = 0;
                var hRatio;
                var wRatio;
                var Ratio = 1;
                var w = this.height;
                var h = this.width;
                wRatio = 500 / this.height;
                hRatio = 500 / this.width;

                if (maxWidth == 0) { //
                    if (hRatio < 1) Ratio = hRatio;
                } else if (maxHeight == 0) {
                    if (wRatio < 1) Ratio = wRatio;
                } else if (wRatio < 1 || hRatio < 1) {
                    Ratio = (wRatio <= hRatio ? wRatio : hRatio);
                }
                if (Ratio < 1) {
                    w = w * Ratio;
                    h = h * Ratio;
                }
                width = h;
                height = w;

                art.dialog({
                    title: '预览',
                    fixed: true,
                    width: width,
                    height: height,
                    id: "image_priview",
                    lock: true,
                    background: "#CCCCCC",
                    opacity: 0,
                    content: '<img src="' + filepath + '"  width="' + width + '" height="' + height + '" />'
                });

            });
        });
    } else {
        Wind.use('artDialog', function () {
            art.dialog({
                title: '预览',
                padding: 0,
                width: 230,
                height: 150,
                content: '<a href="' + filepath + '" target="_blank"><img src="<?php echo $staticUrl; ?>statics/images/icon/down.gif">单击打开</a>',
                lock: true
            });
        });
    }
}
</script>
</body>
</html>